package com.alon.spring01.concurrent;

/**
 * @program: spring01
 * @description: happend-before例子
 * @author: yulongguang
 * @create: 2019-04-11 23:04
 **/
public class Concurrent02 {



    int i=0;
    volatile boolean flag=false;

    /**
     * 写
     */
    public void write(){
        i=1;
        flag=true;
    }
    /**
     * 读
     */
    public void read(){
        if (flag){
            System.out.println("----------i"+i);
        }
    }


}
